package com.yanqu.road.server.cmd.activity.horserun;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HorseRunProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.horserun.CrossHorseRunActivity;
import com.yanqu.road.server.manager.activity.horserun.CrossHorseRunMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import org.dom4j.tree.AbstractComment;

@Cmd(code = CrossProtocol.C_HORSE_RUN_USER_UPDATE_CONDITION_REQ,desc = "跨服更新成就")
public class CrossHorseRunUpdateConditionCmd extends CrossUnionCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {

        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        HorseRunProto.CrossUserUpdateUnionConditionReq req = HorseRunProto.CrossUserUpdateUnionConditionReq.parseFrom(packet.getBytes());
        int actId = req.getActivityId();
        long playerId = packet.getPlayerId();
        CrossHorseRunActivity activity = CrossHorseRunMgr.getActivity(actId, groupId);
        if (activity == null) {
            CrossHorseRunMgr.getLogger().error("玩家请求更新小马快跑活动不存在,活动id{},分组id{},玩家id{}",actId,groupId,playerId);
            return;
        }
        HorseRunProto.CrossUserUpdateConditionToGame.Builder builder = activity.userUpdateUnionCondition(playerId);
        MessageHelper.sendPacket(serverId, packet.getPlayerId(),
                YanQuMessageUtils.buildMessage(GameProtocol.S_HORSE_RUN_UPDATE_CONDITION_RESP,builder.build())
        );


    }

    @Override
    public void sendData() {

    }
}
